home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / netsnake / mainmodu.bas < prev    next >
BASIC Source File  |  1999-07-26  |  2KB  |  80 lines

  1. Attribute VB_Name = "mainModule"
  2. Public Const IN_FILENAME = "f"
  3. Public Const IN_DATA = "o"
  4. Public Const DONE = "d"
  5. Public Const RECEIVED = "i"
  6. Public Const GOT_FILENAME = "k"
  7. Public Const READY = "r"
  8. Public Const BUFFER = "b"
  9.  
  10. Public fullCount As Long
  11. Public Data As String
  12. Public Response As String
  13. Public inFile As String
  14. Public outFile As String
  15.  
  16. Sub WaitFor(WaitFor As String)
  17. On Error Resume Next
  18. Do While Response <> WaitFor
  19. DoEvents
  20. Loop
  21. End Sub
  22.  
  23. Function Parse(ByVal parseStringx, ByVal argNum As Integer) As Variant
  24. On Error Resume Next
  25. Dim lastPos As Integer
  26. Dim subPos As Integer
  27. Dim argPos(1 To 50) As Integer
  28. Dim argContent(1 To 50)
  29. parseString = parseStringx
  30. parseString = Trim(Right(parseString, ((Len(parseString)) - (InStr(parseString, " ")))))
  31.  
  32. parseString = parseString & " " 'save my ass some work
  33.  
  34.  
  35.  
  36. 'count arguments
  37. argCount = 0
  38. Do
  39.     DoEvents
  40.     lastPos = InStr((lastPos + 1), parseString, " ")
  41.     If lastPos = 0 Then Exit Do
  42.     argCount = argCount + 1
  43.     argPos(argCount) = lastPos
  44. Loop
  45. If argCount = 0 Then Exit Function
  46. 'end count arguments
  47.  
  48. 'get argument content
  49. For i = 1 To argCount
  50.     Select Case i
  51.         Case argCount
  52.             If argCount <> 1 Then
  53.                 subPos = argPos(i - 1)
  54.             Else
  55.                 subPos = 1
  56.             End If
  57.         Case 1
  58.             subPos = 1
  59.         Case Else
  60.             subPos = argPos(i - 1)
  61.     End Select
  62.     DoEvents
  63.     argContent(i) = Trim(Mid(parseString, subPos, (argPos(i) - subPos)))
  64. Next i
  65. 'end get argument content
  66.  
  67. Parse = argContent(argNum)
  68. End Function
  69.  
  70.  
  71. Function argArray(ByVal startPos As Integer, endPos As Integer) As String
  72. Dim x As String
  73. Parse comFull, 1
  74. For i = startPos To endPos
  75.     DoEvents
  76.     x = x & Parse(comFull, i) & " "
  77. Next i
  78. argArray = Trim(x)
  79. End Function
  80.